package main;

import factory.Factory;
import factory.Link;
import factory.Page;
import factory.Tray;

// Main类使用抽象工厂 生产的零件 并将零件组装成产品，该类没有使用任何 具体 的零件、产品和工厂
public class Main {

    public static void main(String[] args) {
//        Factory factory = Factory.getFactory("listfactory.ListFactory");
        Factory factory = Factory.getFactory("tablefactory.TableFactory");

        //生产零件
        Link baiDu = factory.createLink("百度", "https://www.baidu.com");
        Link google = factory.createLink("谷歌", "https://google.com/");

        Link vueJsEnglish = factory.createLink("vueJs", "https://vuejs.org/");
        Link vueJsChinese = factory.createLink("vueJs,中文", "https://cn.vuejs.org/");
        Link element = factory.createLink("Element", "https://element.eleme.cn/");
        Link ruoYi = factory.createLink("ruoYi", "https://ruoyi.vip/");

        Tray traySearch = factory.createTray("搜索引擎");
        traySearch.add(baiDu);
        traySearch.add(google);

        Tray trayVueJs = factory.createTray("vueJs");
        trayVueJs.add(vueJsEnglish);
        trayVueJs.add(vueJsChinese);

        Tray trayDoc = factory.createTray("文档");
        trayDoc.add(trayVueJs);
        trayDoc.add(element);
        trayDoc.add(ruoYi);

        //零件组装成产品
//        Page page = factory.createPage("LinkPage", "十画生");
        Page page = factory.createPage("TablePage", "十画生");
        page.add(traySearch);
        page.add(trayDoc);
        page.add(baiDu);
        page.output();

    }
}
